﻿using System.Web;

namespace OpenWaves.Web
{
    public static class HttpRequestExtensions
    {
        public static AbsoluteUrl GetRawUrl(this HttpRequest request)
        {
            return GetRawUrl(new HttpRequestWrapper(request));
        }

        public static RelativeUrl GetRawRelativeUrl(this HttpRequest request)
        {
            return GetRawRelativeUrl(new HttpRequestWrapper(request));
        }

        public static AbsoluteUrl GetRawUrl(this HttpRequestBase request)
        {
            var rawRelativeUrl = request.GetRawRelativeUrl();
            var requestUrl = new AbsoluteUrl(request.Url);
            return rawRelativeUrl.ResolveAgainst(requestUrl);
        }

        public static RelativeUrl GetRawRelativeUrl(this HttpRequestBase request)
        {
            return Url.ParseRelative(request.RawUrl);            
        }         
    }
}